import os
import tdsvis
import functions
def get_scenario_data(directory, prefix, theme=tdsvis.color.continuous.interpolatePuBuGn):
g, pos = functions.get_graph("data/scenario1/evmappinglog", prefix=prefix)
voltage = functions.stacked_data(os.path.join(directory, "datafile_Voltage_magnitude.csv"), "bus")
voltage = functions.add_prefix(voltage, prefix)
load = functions.stacked_data(os.path.join(directory, "datafile_P_loads.csv"), "bus")
load = functions.add_prefix(load, prefix)
load.name = load.name.map(lambda x: x.replace("bus", "load"))
print(voltage.shape)
print(load.shape)
soc = functions.stacked_data(os.path.join(directory, "datafile_soc.csv"), "ev")
network = tdsvis.graphs.Network(g, pos, scale=1, height=300, width=chart_width,
size={'bus': 3, 'ev': 0.75, 'load': 1},
colors={'load': '#2E8B57'}, legend=False)
network.subscribe = ['{}voltage_color'.format(prefix),
'{}voltage_size'.format(prefix),
'{}load_color'.format(prefix),
'{}load_size'.format(prefix),
]
# voltage graphs
vdf = tdsvis.graphs.Line(voltage, x='timestamp', y='name',
ylab="voltage [pu]", xlab="time", values='value',
ylim=voltage_ylim,
xticks=5,
scale=1, height=300, width=chart_width)
vdf.emit_size = tdsvis.size.SizeRange('{}voltage_size'.format(prefix), 3.5, 0.5)
vdf.emit_color = tdsvis.color.ContinuousColor('{}voltage_color'.format(prefix), 0.95, 0.2, theme, voltage_ylim[0], voltage_ylim[1])
# vdf.emit_color = tdsvis.color.ContinuousColor('{}voltage_color'.format(prefix), 0.95, 0.2, theme)
vdf.subscribe = ['{}voltage_color'.format(prefix)]
vleg = tdsvis.graphs.Legend(kind='LegendContinuous', link='{}voltage_color'.format(prefix), label="volt [pu]", height=300, width=75,margin_bottom=50)
# load graphs
ldf = tdsvis.graphs.StackedArea(load, x='timestamp', y='name',
ylim = load_ylim,
xticks=5,
ylab="power [kW]", xlab="time", values='value', scale=1, height=300, width=chart_width)
ldf.emit_size = tdsvis.size.SizeRange('{}load_size'.format(prefix), 1, 3)
ldf.emit_color = tdsvis.color.ContinuousColor('{}load_color'.format(prefix), 0.1, 1, tdsvis.color.continuous.interpolateGreens)
ldf.subscribe = ['{}load_color'.format(prefix)]
lleg = tdsvis.graphs.Legend(kind='LegendContinuous', link='{}load_color'.format(prefix), label="load", height=300, width=75, margin_bottom=50)
sdf = tdsvis.graphs.Line(soc, x='timestamp', y='name',
ylab="state of charge", xlab="time",
xticks=5,
values='value', scale=1, height=300, width=chart_width)
return network, vleg, vdf, lleg, ldf, sdf
tdsvis.initialize_notebook(1200)
chart_width = 260
timestamp = "2018-01-01 17:35:00"
voltage_ylim = [0.930, 1.0]
load_ylim = [0, 1800]
select = tdsvis.select()
initial_state = tdsvis.graphs.InitialState(current_time = timestamp,
color="#FF0000")
play = tdsvis.graphs.Play()
# one scenario
network1, vleg1, vdf1, lleg1, ldf1, s1 = get_scenario_data("data/scenario1/load_data/tdsvis_evdemo/demo_60ev", "one_")
# scenario two
network2, vleg2, vdf2, lleg2, ldf2, s2 = get_scenario_data("data/scenario1/load_data/tdsvis_evdemo/demo_60ev_time_volt_reg", "two_")
#scenario three
network3, vleg3, vdf3, lleg3, ldf3, s3 = get_scenario_data("data/scenario1/load_data/tdsvis_evdemo/demo_60ev_time_volt_reg_delays", "three_")